/**
 * 设置cookie
 * @param {String} cname cookieName
 * @param {String} cvalue cookieValue
 * @param {Number} exTime 过期时间 单位毫秒
 */
export const setCookie = (cname, cvalue, exTime = 2000) => {
  let d = new Date();
  d.setTime(d.getTime() + exTime);
  document.cookie = `${cname}=${cvalue};expires=${d.toUTCString()};path=${window.location.pathname}`;
}
/**
 * 获取cookie
 * @param {String} cname cookieName
 */
export const getCookie = (cname) => {
  let name = cname + "=";
  let ca = document.cookie.split(';');
  for (var i = 0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}